app.controller('columnEditCtrl',['$scope','columnEditService','$stateParams','toaster','$state', function($scope,columnEditService,$stateParams,toaster,$state) {

    $scope.columnEditService=columnEditService;
    $scope.id=$stateParams.id

    //根据id查询栏目
    $scope.findById=function(){
        columnEditService.findById($scope).then(function(result){
            switch (result.status){
                case 200:
                    $scope.columnEditService.column = result.data;
                    break;
                case 662:
                    toaster.pop('waiting', "提示", result.message);
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        });
    }

    $scope.findById();

    //添加模块
    $scope.editColumn=function(){
        columnEditService.editColumn($scope).then(function(result){
            switch (result.status){
                case 200:
                    toaster.pop('success', "提示", "操作成功");
                    $state.go('app.column');
                    break;
                case 662:
                    toaster.pop('waiting', "提示", result.message);
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break;
            }
        })
    }

    }
]);